<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Login Page</title>
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="/static/admin/component/pear/css/pear.css"/>
    <link rel="stylesheet" href="/static/admin/admin/css/other/login.css"/>
</head>
<!-- 代 码 结 构 -->
<body background="/static/admin/admin/images/background2.svg" style="background-size: cover;">
<form id="form" action="{:url()}" method="post" class="layui-form layui-form-pane">
    <div class="layui-form">
        <div class="layui-form-item">
            <img class="logo" src="/static/admin/admin/images/logo.png" />
            <div class="title">Pear Admin</div>
        </div>
        <div class="layui-form-item">
            <input placeholder="账 户 "  id="username" name="username" class="layui-input" />
        </div>
        <div class="layui-form-item">
            <input type="password" placeholder="密 码 " id="password" name="password" class="layui-input" />
        </div>
        <div class="layui-form-item">
            <input type="checkbox" name="" title="记住密码" lay-skin="primary" checked>
        </div>
        {:token()}
        <input type="submit" value="登录" lay-submit="" lay-filter="formLogin" class="layui-btn layui-btn-normal">
    </div>
</form>
<!-- 资 源 引 入 -->
<script src="/static/admin/component/layui/layui.js"></script>
<script src="/static/admin/component/pear/pear.js"></script>
<script>
            window.sessionStorage.clear();
            layui.use(['form', 'layer', 'jquery'], function() {
                var $ = layui.jquery, layer = layui.layer, form = layui.form,captchaUrl = '{:captcha_src()}';
                form.on('submit(formLogin)', function(data) {
                    var that = $(this),
                        account = $('input[name="username"]').val(),
                        pwd = $('input[name="password"]').val();

                    layer.msg('数据提交中...',{time:500000});
                    that.prop('disabled', true);
                    $.ajax({
                        type: "POST",
                        url: "{:url('admin/login/login')}",
                        data: {'username': account, 'password': pwd},
                  dataType:"json",
                        success: function(res) {
                            layer.msg(res.msg, {}, function() {
                                if (res.code == 1) {
                                    window.location.href = "{:url('admin/index/index')}";
                                } else {
                                    that.prop('disabled', false);
                                }
                            });

                        }
                    });
                    return false;
                });

                $(document).on('click', '#captchaImg', function(){
                    $(this).attr('src', captchaUrl+'#rand='+Math.random());
                });
            });
      </script>
</body>
</html>